#ifndef COMSERIE_H
#define COMSERIE_H

#include <QWidget>
#include <QMessageBox>
#include "qextserialenumerator.h"
#include "qextserialport.h"
#include "packet.h"

namespace Ui {
class comSerie;
}

class comSerie : public QWidget
{
    Q_OBJECT
    
public:
    explicit comSerie(QWidget *parent = 0);
    ~comSerie();
    
    //Initialisations
    void init();

    //Accesseurs
    QextSerialPort *getPort();
    QString getPortName();
    QString getPortSpeed();

    //Gestion Lecture/Ecriture
    void writeData(char * data, int length);
    QByteArray readData();
    qint64 bytesAvailable();

private slots:

    //Slots de gestion de la connexion
    void uartToggleConnection();
    void uartConnect();
    void uartDisconnect();
    void refreshConnection();

signals:
    void readyRead();
    void connected();
    void disconnected();

private:

    QextSerialPort *port;
    Ui::comSerie *ui;
};

#endif // COMSERIE_H
